<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<html>
	<head>
		<title>A Free Online Rental Application</title>
		<script LANGUAGE="JavaScript">
	function validateSearchForm() {
		
		if (document.searchForm.state.value == "") {
			alert("State Name should n't be left blank");
			document.searchForm.state.focus();
			return false;
		} else if (document.searchForm.city.value == "") {
			alert("City should n't be left blank");
			document.searchForm.city.focus();
			return false;
		} else if (document.searchForm.location.value == "") {
			alert("Location should n't be left blank");
			document.searchForm.location.focus();
			return false;
		} else if (document.searchForm.rentRange.value == "") {
			alert("rentRange should n't be left blank");
			document.searchForm.rentRange.focus();
			return false;
		}  else {
			document.searchForm.action = "search.do?dispatch=searchHomes";
			document.searchForm.submit();
		}
	}
	function getStateCities(){
	var stateId = document.getElementById('state').value;
	document.searchForm.action = "search.do?dispatch=getCities&stateId="+stateId;
		document.searchForm.submit();
	}
</script>
	</head>
	<body>
		<table width="100%">
			<tr>
				<td align="center" align="left">
					<h4>
						<bean:message key="rental.m1" />
					</h4>
				</td>
				<td align="center">
					<a href="home.do?dispatch=addProperty"><bean:message
							key="rental.addYourProperty" /> </a>
				</td>
				<td align="center">
					<a href="signout.do?dispatch=signout"><bean:message
							key="rental.signout" /> </a>
				</td>
			</tr>
		</table>
		<CENTER>
			<h1>
				<bean:message key="rental.m2" />
			</h1>
			<html:errors />
			<table width="100%">
				<html:form action="search">
					<tr>
					<!-- Maybe - needed in the coming future
						<td>
							<bean:message key="property.country" />
						</td>
						<td>
							<html:text property="country" value="India" />
						</td>
						Maybe - needed in the coming future -->
						<td>
							<bean:message key="property.state" />
						</td>
						<td>
							<html:select property="state"
								onchange="getStateCities()">
								<html:optionsCollection name="states" label="stateName"
									value="statId" />
							</html:select>
						</td>
						<td>
							<bean:message key="property.city" />
						</td>
						<td>
							<html:select property="city">
								<html:optionsCollection name="stateCities" label="cityName"
									value="cityId" />
							</html:select>
						</td>
						<td>
							<bean:message key="property.localtion" />
						</td>
						<td>
							<html:text property="location" value="Ameer Pet" />
						</td>
						<td>
							<bean:message key="property.rentRange" />
						</td>
						<td>
							<html:text property="rentRange" value="100" />
						</td>
						<td>
							<input type="button" value="Search Now!"
								onclick="validateSearchForm()" />
						</td>
					</tr>
				</html:form>
			</table>

			<table width="100%" height="10">
				<tr>
					<td></td>
				</tr>
			</table>
			<table width="100%">
				<tr>
					<td width="75%">
						<table BORDER=5 width="75%">
							<logic:present name="homes">
								<logic:iterate id="home" name="homes">
									<TR>
										<td></td>
									</TR>
									<TR>
										<TD ALIGN="left">
											&nbsp;
											<B><bean:message key="property.name" /> </B> &nbsp;
											<bean:write name="home" property="name" />
											</br>
											<B><bean:message key="property.rent" /> </B>&nbsp;
											<bean:write name="home" property="rent" />
											</br>
											<B><bean:message key="property.noOfMembersAllowed" /> </B>&nbsp;
											<bean:write name="home" property="noOfMembersAllowed" />
											</br>
											<B><bean:message key="property.maintenanceCost" /> </B>&nbsp;
											<bean:write name="home" property="maintenanceCost" />
											</br>
											<B><bean:message key="property.rentNegotiable" /> </B>&nbsp;
											<bean:write name="home" property="rentNegotiable" />
										</TD>

										<TD ALIGN="left">
											&nbsp;
											<B> <bean:message key="property.petsAllowed" /> </B> -
											&nbsp;
											<bean:write name="home" property="petsAllowed" />
											</br>
											<B><bean:message key="property.zipCode" /> </B> - &nbsp;
											<bean:write name="home" property="zipCode" />
											</br>
											<B><bean:message key="property.cityName" /> </B>&nbsp;
											<bean:write name="home" property="cityName" />
											</br>
											<B><bean:message key="property.stateName" /> </B>&nbsp;
											<bean:write name="home" property="stateName" />
											</br>
										</TD>
									</TR>
									<TR>
										<td colspan="2">
											<B><bean:message key="property.message" /> </B>&nbsp;
											<bean:write name="home" property="message" />
										</td>
									</TR>
									<TR>
										<td></td>
									</TR>
								</logic:iterate>
							</logic:present>
						</table>
					</td>
					<td></td>
				</tr>
			</table>
		</CENTER>
	</body>
</html>
